/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * BanVeFrm.java
 *
 * Created on May 27, 2011, 9:49:22 AM
 */
package gui;

import dao.ChuyenBayDAO;
import dao.DonGiaDAO;
import dao.HangVeDAO;
import dao.HanhKhachDAO;
import dao.TuyenBayDAO;
import dao.VeChuyenBayDAO;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import pojo.ChuyenBayPOJO;
import pojo.DonGiaPOJO;
import pojo.HangVePOJO;
import pojo.HanhKhachPOJO;
import pojo.TuyenBayPOJO;
import pojo.VeChuyenBayPOJO;

/**
 *
 * @author b2
 */
public class BanVeFrm extends javax.swing.JFrame {

    private String maChuyenBay;
    private String maHanhKhach;
    private String maHangVe;
    private double giaTien;
    private int soVe = 0;

    /** Creates new form BanVeFrm */
    public BanVeFrm() {
        initComponents();
    }

    public void initBanVe() {
        ArrayList<ChuyenBayPOJO> ds = ChuyenBayDAO.LayDanhSachChuyenBay();
        String[] dscb = new String[ds.size()];
        for (int i = 0; i < ds.size(); i++) {
            ChuyenBayPOJO cb = ds.get(i);
            dscb[i] = cb.getMaChuyenBay();
        }
        DefaultComboBoxModel dcm = new DefaultComboBoxModel(dscb);
        this.jcbMaChuyenBay.setModel(dcm);
        // hạng vé
        ArrayList<HangVePOJO> dsHangVe = HangVeDAO.LayDanhSachDangVe();
        String[] dshv = new String[dsHangVe.size()];
        for (int i = 0; i < dsHangVe.size(); i++) {
            dshv[i] = dsHangVe.get(i).getMaHangVe();
        }
        DefaultComboBoxModel hvmodel = new DefaultComboBoxModel(dshv);
        this.jcbHangVe.setModel(hvmodel);
        //hanh kahc
        this.txtMaKhachHang.setText("");
        this.txtHanhKhach.setText("");
        this.txtCMND.setText("");
        this.txtDienThoai.setText("");
        //end khach hang
        this.setTenHangVe();
        this.thongTinVe();

    }

    public void setTenHangVe() {
        maHangVe = (String) this.jcbHangVe.getSelectedItem();
        HangVePOJO hangVe = HangVeDAO.LayDangVe(maHangVe);
        this.txtHangVe.setText(hangVe.getTenHangVe());
    }

    public void setGiaTien(String maDonGia) {
        DonGiaPOJO dg = DonGiaDAO.layDonGia(maDonGia);
        giaTien = dg.getDonGia();
        this.txtGiaVe.setText(Double.toString(giaTien));
    }

    public void thongTinVe() {
        maChuyenBay = (String) this.jcbMaChuyenBay.getSelectedItem();
        ChuyenBayPOJO cb = ChuyenBayDAO.LayChuyenBay(maChuyenBay);
        String maTuyenBay = cb.getMaTuyenBay();
        String strNgaygio = cb.getNgayGio();

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); //please notice the capital M
        Date ngaygio = null;
        try {
            ngaygio = formatter.parse(strNgaygio);
        } catch (ParseException ex) {
            Logger.getLogger(BanVeFrm.class.getName()).log(Level.SEVERE, null, ex);
        }
        TuyenBayPOJO tb = TuyenBayDAO.LayTuyenBay(maTuyenBay);
        String sanbayDi = null;
        String sanbayDen = null;
        sanbayDi = tb.getSanBayDi();
        sanbayDen = tb.getSanBayDen();
        String SoLuongVeTrong = Integer.toString(ChuyenBayDAO.soGheTrong(maChuyenBay));
        soVe = Integer.parseInt(SoLuongVeTrong);
        this.txtSanBayDi.setText(sanbayDi);
        this.txtSanBayDen.setText(sanbayDen);
        this.txtTinhTrangVe.setText(SoLuongVeTrong);
        this.jdcNgayDat.setDate(ngaygio);
        String maDonGia = maTuyenBay + "-" + (String) this.jcbHangVe.getSelectedItem();
        this.setGiaTien(maDonGia);
    }

    public void thongtinHanhKhach() {
        maHanhKhach = this.txtMaKhachHang.getText();
        HanhKhachPOJO hk = HanhKhachDAO.LayThongTinHanhKhach(maHanhKhach);
        this.txtMaKhachHang.setText(hk.getMaHanhKhach());
        this.txtHanhKhach.setText(hk.getTenHanhKhach());
        this.txtCMND.setText(hk.getCMND());
        this.txtDienThoai.setText(hk.getDienThoai());
    }

    public void luuVe() {
        VeChuyenBayPOJO ve = new VeChuyenBayPOJO();
        ve.setGiaTien(giaTien);
        ve.setMaHangVe(maHangVe);
        ve.setMaChuyenBay(maChuyenBay);
        ve.setmHanhKhach(maHanhKhach);
        this.updateSoGhe();
        boolean kq = VeChuyenBayDAO.themVeChuyenBay(ve);
        if (kq == true) {
            JOptionPane.showMessageDialog(this, "thêm thành công");
        } else {
            JOptionPane.showMessageDialog(this, "Thêm thất bại");
        }

    }

    public void updateSoGhe() {
        int soghe = Integer.parseInt(this.txtTinhTrangVe.getText()) - 1;
        this.txtTinhTrangVe.setText(Integer.toString(soghe));
        ChuyenBayDAO.updateSoLuongGhe(maChuyenBay, soghe);
    }

    public void laytMaHanhKhach(String maHK) {
        maHanhKhach = maHK;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jcbMaChuyenBay = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        txtSanBayDi = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtSanBayDen = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtTinhTrangVe = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        txtMaKhachHang = new javax.swing.JTextField();
        txtCMND = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        txtHanhKhach = new javax.swing.JTextField();
        txtDienThoai = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jcbHangVe = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        txtGiaVe = new javax.swing.JTextField();
        btnLuu = new javax.swing.JButton();
        btnTaoMoi = new javax.swing.JButton();
        btnThoat = new javax.swing.JButton();
        txtHangVe = new javax.swing.JTextField();
        btnThemDonGia = new javax.swing.JButton();
        jdcNgayDat = new com.toedter.calendar.JDateChooser();
        btnHanhKhach = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel7 = new javax.swing.JLabel();
        btnHienThi = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Bán vé chuyến bay");
        setBounds(new java.awt.Rectangle(200, 200, 0, 0));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24));
        jLabel1.setText("BÁN VÉ  CHUYẾN BAY");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Bán vé chuyến bay"));

        jLabel2.setText("Mã chuyến bay");

        jcbMaChuyenBay.setPreferredSize(new java.awt.Dimension(60, 20));
        jcbMaChuyenBay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbMaChuyenBayActionPerformed(evt);
            }
        });

        jLabel3.setText("Sân bay đi");

        txtSanBayDi.setEditable(false);

        jLabel4.setText("Sân bay đến");

        txtSanBayDen.setEditable(false);

        jLabel5.setText("Ngày giờ");

        jLabel6.setText("Tình trạng vé");

        txtTinhTrangVe.setEditable(false);

        jLabel8.setText("CMND");

        txtMaKhachHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtMaKhachHangActionPerformed(evt);
            }
        });

        txtCMND.setEnabled(false);

        jLabel9.setText("Hành khách");

        jLabel10.setText("Điện thoại");

        txtHanhKhach.setEnabled(false);

        txtDienThoai.setEnabled(false);

        jLabel11.setText("Hạng vé");

        jcbHangVe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbHangVeActionPerformed(evt);
            }
        });

        jLabel12.setText("Giá vé");

        txtGiaVe.setEditable(false);
        txtGiaVe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtGiaVeActionPerformed(evt);
            }
        });

        btnLuu.setText("Lưu");
        btnLuu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLuuActionPerformed(evt);
            }
        });

        btnTaoMoi.setText("Tạo mới");
        btnTaoMoi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTaoMoiActionPerformed(evt);
            }
        });

        btnThoat.setText("Thoát");
        btnThoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnThoatActionPerformed(evt);
            }
        });

        txtHangVe.setEditable(false);

        btnThemDonGia.setText("Thêm đơn giá");
        btnThemDonGia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnThemDonGiaActionPerformed(evt);
            }
        });

        jdcNgayDat.setDateFormatString("MM/dd/yyyy hh:mm:ss a");
        jdcNgayDat.setEnabled(false);

        btnHanhKhach.setText("Hành khách");
        btnHanhKhach.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHanhKhachActionPerformed(evt);
            }
        });

        jLabel7.setText("Mã hành khách");

        btnHienThi.setText("Hiện thị");
        btnHienThi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHienThiActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(167, 167, 167)
                .addComponent(btnLuu)
                .addGap(73, 73, 73)
                .addComponent(btnTaoMoi)
                .addGap(81, 81, 81)
                .addComponent(btnThoat)
                .addContainerGap(139, Short.MAX_VALUE))
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 641, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(56, 56, 56)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(125, 125, 125)
                        .addComponent(jcbHangVe, 0, 102, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(135, 135, 135)
                        .addComponent(txtGiaVe, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5)
                            .addComponent(jLabel9)
                            .addComponent(jLabel7))
                        .addGap(16, 16, 16)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(76, 76, 76)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jdcNgayDat, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                                    .addComponent(txtSanBayDi, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                                    .addComponent(jcbMaChuyenBay, 0, 102, Short.MAX_VALUE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(34, 34, 34)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(txtHanhKhach, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtMaKhachHang, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel6))
                                .addGap(38, 38, 38)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtTinhTrangVe)
                                    .addComponent(txtSanBayDen, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(btnThemDonGia)
                            .addComponent(txtHangVe, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtDienThoai, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnHienThi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtCMND, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnHanhKhach)))))
                .addGap(23, 23, 23))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 631, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jcbMaChuyenBay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(txtSanBayDen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtSanBayDi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel5)
                        .addComponent(jLabel6)
                        .addComponent(txtTinhTrangVe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jdcNgayDat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMaKhachHang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(txtCMND, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnHanhKhach)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtHanhKhach, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(txtDienThoai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnHienThi))
                .addGap(22, 22, 22)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel11)
                        .addComponent(jcbHangVe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(txtHangVe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtGiaVe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnThemDonGia)
                            .addComponent(jLabel12))
                        .addGap(50, 50, 50)))
                .addGap(42, 42, 42)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnLuu)
                    .addComponent(btnTaoMoi)
                    .addComponent(btnThoat))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(245, 245, 245)
                        .addComponent(jLabel1)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(36, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        this.initBanVe();

    }//GEN-LAST:event_formWindowOpened

    private void jcbMaChuyenBayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbMaChuyenBayActionPerformed
        // TODO add your handling code here:
        this.thongTinVe();
    }//GEN-LAST:event_jcbMaChuyenBayActionPerformed

    private void jcbHangVeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbHangVeActionPerformed
        // TODO add your handling code here:
        this.setTenHangVe();
    }//GEN-LAST:event_jcbHangVeActionPerformed

    private void btnThemDonGiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThemDonGiaActionPerformed
        // TODO add your handling code here:
        QDDonGiaHangVeFrm frm = new QDDonGiaHangVeFrm();
        frm.setVisible(true);
    }//GEN-LAST:event_btnThemDonGiaActionPerformed

    private void btnLuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuActionPerformed
        // TODO add your handling code here:
        if(soVe > 0){
        this.luuVe();
        }else{
        JOptionPane.showMessageDialog(this, "Hết vé");
        }
    }//GEN-LAST:event_btnLuuActionPerformed

    private void btnHanhKhachActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHanhKhachActionPerformed
        // TODO add your handling code here:
        HanhKhachFrm frm = new HanhKhachFrm();
        frm.setVisible(true);
    }//GEN-LAST:event_btnHanhKhachActionPerformed

    private void txtGiaVeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtGiaVeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtGiaVeActionPerformed

    private void txtMaKhachHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMaKhachHangActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtMaKhachHangActionPerformed

    private void btnHienThiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHienThiActionPerformed
        // TODO add your handling code here:
        this.thongtinHanhKhach();
    }//GEN-LAST:event_btnHienThiActionPerformed

    private void btnTaoMoiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTaoMoiActionPerformed
        // TODO add your handling code here:
        if(soVe > 0){
        this.initBanVe();
        }else{
        JOptionPane.showMessageDialog(this, "Hết vé");
        }
    }//GEN-LAST:event_btnTaoMoiActionPerformed

    private void btnThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThoatActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_btnThoatActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new BanVeFrm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnHanhKhach;
    private javax.swing.JButton btnHienThi;
    private javax.swing.JButton btnLuu;
    private javax.swing.JButton btnTaoMoi;
    private javax.swing.JButton btnThemDonGia;
    private javax.swing.JButton btnThoat;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JComboBox jcbHangVe;
    private javax.swing.JComboBox jcbMaChuyenBay;
    private com.toedter.calendar.JDateChooser jdcNgayDat;
    private javax.swing.JTextField txtCMND;
    private javax.swing.JTextField txtDienThoai;
    private javax.swing.JTextField txtGiaVe;
    private javax.swing.JTextField txtHangVe;
    private javax.swing.JTextField txtHanhKhach;
    private javax.swing.JTextField txtMaKhachHang;
    private javax.swing.JTextField txtSanBayDen;
    private javax.swing.JTextField txtSanBayDi;
    private javax.swing.JTextField txtTinhTrangVe;
    // End of variables declaration//GEN-END:variables
}
